#ifndef STORAGE_VEHICLE_SURROGATE_H
#define STORAGE_VEHICLE_SURROGATE_H


#include <iostream>
#include "vehicle.h"
using std::cout;
using std::endl;

class VehicleSurrogate {
public:
	VehicleSurrogate() : vp(0) {};

	VehicleSurrogate(const VehicleSurrogate& v) : vp(v.vp ? v.vp->clone() : 0){};

	VehicleSurrogate(const Vehicle& v) : vp(v.clone()){};

	~VehicleSurrogate() {if	(!vp) delete vp;};

	VehicleSurrogate& operator=(const VehicleSurrogate& v){
		if (this != &v)
		{
			if	(!vp) delete vp;
			vp = (v.vp ? v.vp->clone() : 0);
		}
		return *this;
	}

	double weight() const {
		if (vp == 0)
		{
			cout << "erro" << endl;
		}
		return vp->weight();
	}

	void start() const {
		if (vp == 0)
		{
			cout << "erro" << endl;
		}
		vp->start();
	}

private:
	Vehicle* vp;

};
#endif